﻿using BodaNetCommunications.Utilities.ComTypes;

namespace BodaNetCommunications.Nodes
{
    public interface IRequestNode
    {
        /// <summary>
        /// 设备号
        /// </summary>
        public long DeviceId { get; set; }

        /// <summary>
        /// 采集节点序号，用于多节点采集区分
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 对应数据库字段名
        /// </summary>
        public string? DataFieldName { get; set; }

        /// <summary>
        /// 采集间隔(单位: ms)
        /// </summary>
        public int Interval { get; set; }

        /// <summary>
        /// PLC数据类型
        /// </summary>
        public DataType? PlcDataFormat { get; set; }

        /// <summary>
        /// 采集地址
        /// </summary>
        public string? NodeAddress { get; set; }

        /// <summary>
        /// 数据块名称
        /// </summary>
        public int Db { get; set; }

        /// <summary>
        /// 开始地址
        /// </summary>
        public int StartAddr { get; set; }

        /// <summary>
        /// 数据长度
        /// </summary>
        public int Count { get; set; }

        /// <summary>
        /// 数据位
        /// </summary>
        public byte Bit { get; set; }

        #region 读取数据要求
        /// <summary>
        /// 读取数据规则
        /// </summary>
        public ReadTypeEnum ReadType { get; set; }

        /// <summary>
        /// 读值结果
        /// </summary>
        public object? ReadVarValue { get; set; }
        /// <summary>
        /// 前一次的数据结果
        /// </summary>
        public object? ReadVarPreValue { get; set; }
        /// <summary>
        /// 数据是否发生变化
        /// </summary>
        public bool ReadValueChanged { get; set; }

        /// <summary>
        /// 掉线
        /// </summary>
        public bool Offline { get; set; }

        /// <summary>
        /// 读值结果转换的类型
        /// </summary>
        public DeviceValueTypeEnum? ReadVarType { get; set; }
        #endregion

        /// <summary>
        /// 根据DataType去写值
        /// </summary>
        public object? WriteVarValue { get; set; }

        /// <summary>
        ///  额外信息
        /// </summary>
        public string? ExtraProperty { get; set; }

        /// <summary>
        ///  备注信息
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        ///  组别
        /// </summary>
        public string? Group { get; set; }

        /// <summary>
        ///  事件名称
        /// </summary>
        public string? EventName { get; set; }

        /// <summary>
        /// Modbus的功能码
        /// </summary>
        public FunctionCodeEnum? FunctionCode { get; set; }

        public EndianType EndianType { get; set; }

        public string? Message { get; set; }

        /// <summary>
        /// 相同类别的区分
        /// </summary>
        public string? Category { get; set; }

        /// <summary>
        /// 设备号
        /// </summary>
        public string? DeviceCode { get; set; }

        /// <summary>
        /// 是否周期采集节点
        /// </summary>
        public bool IsPeriodicNode { get; set; }

        /// <summary>
        /// 是否状态节点
        /// </summary>
        public bool IsStateNode { get; set; }

        /// <summary>
        /// 是否报警节点
        /// </summary>
        public bool IsAlarmNode { get; set; }


        public double TimeCost { get; set; }
    }

}
